import http from "@/utils/request";

const apiPrefix = "/goods";


export async function addGood(data) {
  return await http.request({
    data: data,
    url: apiPrefix+'/addGoodsWithSpecification',
    method: 'post'
  })
}
export async function getPanel() {
  return await http.request({
    url: '/panel',
    method: 'get'
  })
}

export async function deleteGoodById(id){
    return await http.request({
        params: {
            id
        },
        url: apiPrefix+'/id',
        method: 'delete'
    })
}

export async function deleteGoodByIds(ids){
    return await http.request({
        params: {
            ids
        },
        url: apiPrefix+'/batch',
        method: 'delete'
    })
}


export async function searchGoodById(id){
    return await http.request({
        params: {
            id
        },
        url: apiPrefix+'/goodsInfo',
        method: 'get'
    })
}

export async function searchGood(params){
    return await http.request({
        params: params,
        url: apiPrefix,
        method: 'get'
    })
}

export async function searchGoodByPage(params){
    return await http.request({
        params: params,
        url: apiPrefix+'/filtrateByTypeAdmin',
        method: 'get'
    })
}


export async function updateGoodById(data){
  return await http.request({
    data: data,
    url: apiPrefix,
    method: 'put'
  })
}

export async function updateGoodStateById(data){
  return await http.request({
    data: data,
    url: apiPrefix+'/updateStatus',
    method: 'put'
  })
}



export async function searchGoodSpecificationInfoByAttr(data){
  return await http.request({
    data,
    url: '/goodsSpecification/specificationInfo',
    method: 'post'
  })
}

export async function addGoodSpecificationInfo(data){
  return await http.request({
    data,
    url: '/goodsSpecification/add',
    method: 'post'
  })
}
export async function deleteGoodSpecificationInfoById(id){
  return await http.request({
    params:{
      id
    },
    url: '/goodsSpecification/id',
    method: 'delete'
  })
}
